//
//  PSStatistics.h
//  PrefCore
//
//  Created by Sergey on 2/23/14.
//  Copyright (c) 2014 Play-on-smart. All rights reserved.
//

#import <Foundation/Foundation.h>
#include "PSBid.h"
#include "PSPlayer.h"

/// Represents statistics on games.
@interface PSGameStatistics : NSObject

/// Number of games played so far.
@property (nonatomic, readwrite) uint64_t played;
/// Total score for rating.
@property (nonatomic, readwrite) uint64_t pool;
/// Number of deleted games
@property (nonatomic, readwrite) uint64_t deleted;

/// Add another game stats to this object.
/// @param other The statistics to be added.
-(void) add:(PSGameStatistics*)other;

@end

/// Represents statistics on sets.
@interface PSSetStatistics : NSObject

/// Total number of deals.
@property (nonatomic, readwrite) uint64_t deals;
/// Total number of passing sets.
@property (nonatomic, readwrite) uint64_t passing;

/// Add another set stats to this object.
/// @param other The statistics to be added.
-(void) add:(PSSetStatistics*)other;

@end

/// Represents aggregation data.
@interface PSAggregationStatistics : NSObject

@property (nonatomic, readwrite) uint64_t sets;

@property (nonatomic, readwrite) uint64_t tricks;

@property (nonatomic, readwrite) uint64_t success;

-(void) add:(PSAggregationStatistics*)other;

@end

@interface PSPercentage : NSObject

@property (nonatomic, readonly) uint64_t total;

@property (nonatomic, readonly) NSString *percentageOfSuccess;

-(instancetype)initWithTotal:(uint64_t)total andSuccess:(uint64_t)success;

@end

@interface PSRatio : NSObject

@property (nonatomic, readonly) uint64_t x;

@property (nonatomic, readonly) uint64_t y;

-(instancetype)initWithX:(uint64_t)x andY:(uint64_t)y;

@end

/// Represents various statistics collected by the program.
@interface PSStatistics : NSObject

/// Number of games played so far.
@property (nonatomic, readwrite) uint64_t numOfGames;
/// Total played pool.
@property (nonatomic, readwrite) uint64_t totalPool;
/// Total score.
@property (nonatomic, readwrite) uint64_t totalAmount;

/// Represents game statistics.
@property (nonatomic, readonly) PSGameStatistics *games;

@property (nonatomic, readonly) PSSetStatistics *sets;

@property (nonatomic, readonly) uint64_t *score;

@property (nonatomic, readonly) uint64_t *withoutThree;

@property (nonatomic, readonly) uint64_t *passes;

@property (nonatomic, readonly) uint64_t *passingTricks;

@property (nonatomic, readonly) PSAggregationStatistics * __strong * misere;

@property (nonatomic, readonly) PSAggregationStatistics * __strong * whists;

/// Update statistics for trick taking of the given player.
-(void)updateTrickingForPlayerId:(PSPlayerId)playerId
                        contract:(PSTrickCount)contract
                          tricks:(PSTrickCount)tricks;

@property (nonatomic, readonly) NSArray* averageScore;

@property (nonatomic, readonly) uint64_t numberOfTrickingSets;

-(NSArray*) trickingSetResultForContract:(PSTrickCount)contract;

@property (nonatomic, readonly) NSArray* averagePassingTricks;

@property (nonatomic, readonly) NSArray* misereSetResult;

@property (nonatomic, readonly) NSArray* whistedSets;

@property (nonatomic, readonly) NSArray* ratioWhistsToPasses;

/// This method is for unit testing.
-(PSAggregationStatistics*)trickingOfPlayer:(PSPlayerId)playerId forContract:(PSTrickCount)contract;

@end
